package com.shelpe.services.sinbad.entity.jpa.vo;

import java.util.Date;

import javax.persistence.Convert;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat.Shape;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.shelpe.services.sinbad.controller.LogDto.LogNoteable;
import com.shelpe.services.sinbad.entity.jpa.OnlineStatus;
import com.shelpe.services.sinbad.service.utils.EntityUtils.OnlineStatusConverter;

import lombok.Data;

@Data
@JsonInclude(Include.NON_NULL)
public class AdgroupVo implements LogNoteable {
	@JsonProperty("note_in")
	private boolean noteIn = true;

	@JsonProperty("adgroup_id")
	private long autoID;
	private String nick;
	@JsonProperty("user_id")
	private long userID;
	@JsonProperty("campaign_id")
	private long campaignID;
	@JsonProperty("category_ids")
	private String categoryIDs;

	@JsonProperty("num_iid")
	private long productID;
	@JsonProperty("title")
	private String productName;
	@JsonProperty("img_url")
	private String productUrl;

	@JsonProperty("default_price")
	private int defaultPrice;

	@JsonProperty("online_status")
	@Convert(converter = OnlineStatusConverter.class)
	private OnlineStatus onlineStatus;

	@JsonProperty("modified_time")
	@JsonFormat(shape = Shape.STRING, pattern = "yyyy-MM-dd")
	private Date modifiedTime;
	@JsonProperty("create_time")
	@JsonFormat(shape = Shape.STRING, pattern = "yyyy-MM-dd")
	private Date createTime;
	@JsonProperty("old_limit")
	private int oldLimit;
	@JsonProperty("new_limit")
	private int newLimit;
	@JsonProperty("old_mobile_discount")
	private int oldMobileDiscount;
	@JsonProperty("new_mobile_discount")
	private int newMobileDiscount;
	@JsonProperty("new_drive_type")
	private int newDriveType;
	@JsonProperty("old_drive_type")
	private int oldDriveType;

	public static enum Status {
		idle(0), updating(1), paused(2), waitingConfirm(-1), blank(-9);

		private int value;

		private Status(int v) {
			this.value = v;
		}

		public int getValue() {
			return this.value;
		}

		public static Status from(int value) {
			Status en = Status.idle;
			for (Status s : Status.values()) {
				if (s.getValue() == value) {
					en = s;
					break;
				}
			}
			return en;
		}
	}

}
